package com.yanu.t2s.controller;

import com.yanu.t2s.entity.User;
import com.yanu.t2s.entity.Yangzhi;
import com.yanu.t2s.service.UserService;
import net.minidev.json.JSONObject;
import com.yanu.t2s.service.YangzhiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/")
public class LoginController {
    @Autowired
    UserService userService;
    @RequestMapping(value = "login",method={RequestMethod.POST, RequestMethod.GET},produces = "application/json;charset=UTF-8")
    String Login(@RequestParam String name,@RequestParam String password ) {
        JSONObject result = new JSONObject();
        User user=userService.getUserByName(name);
        System.out.println(user.toString());
       // System.out.println(name+"  "+password+" "+usertype);
        if(name.equals(user.getName())&&password.equals(user.getPassword())) {
            return user.toString();
        }
        else {
            return "登录失败";
        }
    }
}
